package com.yuanqi.repository;

import com.yuanqi.domain.Account;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface AccountRepository extends JpaRepository<Account, Long> {
    
    Optional<Account> findByAccountNumber(String accountNumber);
    
    List<Account> findByStatus(Integer status);
    
    @Query("SELECT SUM(a.balance) FROM Account a WHERE a.status = 1")
    Double getTotalBalance();
    
    boolean existsByAccountNumber(String accountNumber);
}


